package org.example.xmut.qa.service.application.service;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.xmut.qa.service.application.command.CreateQaCommand;
import org.example.xmut.qa.service.application.port.in.CreateQaUseCase;
import org.example.xmut.qa.service.domain.Qa;
import org.example.xmut.qa.service.domain.port.CreateQaPort;
import org.example.xmut.qa.service.domain.valueobject.Answer;
import org.example.xmut.qa.service.domain.valueobject.QaId;
import org.example.xmut.qa.service.domain.valueobject.Question;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class CreateQaService implements CreateQaUseCase {
    @Resource
    private CreateQaPort createQaPort;
    @Override
    public Qa createQa(CreateQaCommand createQaCommand) {
        //command -> domain
        Qa qa=new Qa(
                new Question(createQaCommand.question()), new Question(createQaCommand.question()),
                new Answer(createQaCommand.answer())
        );
        log.info("qa:{}",qa);
        return createQaPort.createQa(qa);
    }
}
